package rentalStore;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

/**
 *
 * @author 
 */
public class SessionFactory implements SessionFactoryRemote {
    
    private static ManagerSessionRemote managerStub;
    
    public ClientSessionRemote createClientSession(String name) throws RemoteException {
        ClientSessionRemote csr = new ClientSession(name);
        ClientSessionRemote stub = (ClientSessionRemote) UnicastRemoteObject.exportObject(csr,0);
        return stub;
    }
    
    public ManagerSessionRemote getManagerSession() throws RemoteException {
        if(managerStub == null) {
            ManagerSessionRemote msr = new ManagerSession();
            managerStub = (ManagerSessionRemote) UnicastRemoteObject.exportObject(msr,0);
        }
        return managerStub;
    }
    
}
